package com.hyt.it.ogt.ks.feign.hystrix;

import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.core.exception.NestedBusinessException;
import com.hyt.core.util.FastJsonUtil;
import com.hyt.it.ogt.cj.model.vo.ProjectCollectInfoVo;
import com.hyt.it.ogt.ks.enums.BizStatusCode;
import com.hyt.it.ogt.ks.feign.KwClient;
import com.hyt.it.ogt.ks.feign.model.*;
import com.hyt.it.ogt.ks.model.vo.*;
import com.hyt.it.ogt.ks.model.vo.login.LoginInfo;
import com.hyt.it.ogt.ks.websocket.WebsocketSendMessageDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  考务接口
 * </p>
 *
 * @author linjd
 * @since 2020/6/10 16:42
 */
@Slf4j
@Component
public class KwClientHystrix implements KwClient {
    @Override
    public String getExamInfo(String examId) {
        log.error("获取考务考试信息失败.进入熔断，请检查考务模块服务");
        return FastJsonUtil.getBeanToJson(ApiResponse.<String>builder().code(BizStatusCode.SERVICE_ERROR.getCode()).build());
    }

    @Override
    public String getExamCandidateInfo(String examId, String admissionNumber) {
        log.error("获取考务考试考试信息.进入熔断，请检查考务模块服务");
        return FastJsonUtil.getBeanToJson(ApiResponse.<String>builder().code(BizStatusCode.SERVICE_ERROR.getCode()).build());
    }

    @Override
    public String getAgreement(String examId) {
        log.error("获取考务考试须知.进入熔断，请检查考务模块服务");
        return FastJsonUtil.getBeanToJson(ApiResponse.<String>builder().code(BizStatusCode.SERVICE_ERROR.getCode()).build());
    }

    @Override
    public List<ProjectCollectInfoVo> queryByProjectId(String examId) {
        log.error("获取考务配置信息.进入熔断，请检查考务模块服务");
        return null;
    }

    @Override
    public String getCandidatePaperInfo(String candidateId) {
        log.error("获取考务考生试卷信息.进入熔断，请检查考务模块服务");
        return FastJsonUtil.getBeanToJson(ApiResponse.<String>builder().code(BizStatusCode.SERVICE_ERROR.getCode()).build());
    }

    @Override
    public String updateCandidateInfo(String examId, String candidateId, String infoData) {
        log.error("更新学生信息错误,进入熔断,请检查考务模块服务");
        return FastJsonUtil.getBeanToJson(ApiResponse.<String>builder().code(BizStatusCode.SERVICE_ERROR.getCode()).build());

    }

    @Override
    public String updateCandidateInfo(String json) {
        log.error("更新考务考生信息失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("更新考务考生信息失败");
    }

    @Override
    public String getExamConfig(String examId) {
        log.error("获取考试配置.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("获取考试配置失败");
    }
    
    @Override
    public String getCandidateInfos(String examId,String candidateId) {
        log.error("获取考生配置信息错误,进入熔断,请检查考务模块服务");
        return FastJsonUtil.getBeanToJson(ApiResponse.<String>builder().code(BizStatusCode.SERVICE_ERROR.getCode()).build());

    }

    @Override
    public String selectCandidateInfo(String candidateId) {
        log.error("获取考试信息失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("获取考试信息失败");
    }

    @Override
    public String queryCandidateInfo(String candidateId) {
        log.error("获取考生信息失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("获取考生信息失败");
    }

    @Override
    public String registerStudent(String json) {
        log.error("注册获取考生信息失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("注册获取考生信息失败");
    }

    @Override
    public String login(String randomId, String code,Integer isScan) {
        log.error("考生登录失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("考生登录失败");
    }

    @Override
    public String getSign(String examId, String userId, Integer videoFrom) {
        log.error("获取签名失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("获取签名失败");
    }

    @Override
    public String selectCandidateBaseInfoForMonitor(String candidateId) {
        log.error("获取考生信息失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("获取考生信息失败");
    }

    @Override
    public String updateMobileMonitorPhoto(String examId, String examCandidateId, String imageUrlA, String imageUrlB,
                                           String url, Integer dualMonitoringState) {
        log.error("上传照片失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("上传照片失败");
    }

    @Override
    public String getFaceUrl(String examId, String examCandidateId, String url, String from) {
        log.error("人脸核身失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("人脸核身失败");
    }

    @Override
    public String uploadPhoto(String json) {
        log.error("抓拍照片上传失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("抓拍照片上传失败");
    }

    @Override
    public String getValidResultPhoto(String examCandidateId, String orderId) {
        log.error("获取人脸核身验证结果照片失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("获取人脸核身验证结果照片失败");
    }

    @Override
    public String getDualMonitoringStates(String examCandidateId) {
        log.error("获取双机位状态失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("获取双机位状态失败");
    }

    @Override
    public String getPaperData(String paperId, String paperVersion) {
        log.error("获取考务考生试卷信息.进入熔断，请检查考务模块服务");
        return FastJsonUtil.getBeanToJson(ApiResponse.<String>builder().code(BizStatusCode.SERVICE_ERROR.getCode()).build());
    }

    @Override
    public String getPaperDataSimple(String paperId, String paperVersion) {
        log.error("获取考务考生试卷信息.进入熔断，请检查考务模块服务");
        return FastJsonUtil.getBeanToJson(ApiResponse.<String>builder().code(BizStatusCode.SERVICE_ERROR.getCode()).build());
    }

    @Override
    public String updateInterruptStatus(String examCandidateId, Integer newState, Integer oldState) {
        log.error("更新考务状态失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("更新考务失败");
    }
    
    @Override
    public String isExistsSubjective(String examCandidateId) {
        log.error("获取试卷是否有主观题失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("人获取试卷是否有主观题失败");
    }

    @Override
    public ApiResponse<String> validCandidateAccount(String examId, String admissionNumber, String from, String loginType) {
        log.error("校验账号是否存在失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("校验账号是否存在失败");
    }

    @Override
    public String updateCandidateOnlineExamState(String examId, String examCandidateId, Boolean onlineExamState,
                                                 Integer state) {
        log.error("修改考生是否在线状态失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("修改考生是否在线状态失败");
    }
    
    @Override
    public String getImageStandard(String projectCollectInfoId) {
        log.error("获取附件标准信息失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("获取附件标准信息失败");
    }
    
    @Override
    public String getStateByAdmissionNumber(String examId, String admissionNumber) {
        log.error("获取考生状态考试考试信息失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("获取考生状态考试考试信息失败");
    }

    @Override
    public String startRecordVideo(String roomId, String userId, Integer from) {
        log.error("开始录制视频失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("开始录制视频信息失败");
    }

    @Override
    public String faceCompareByUrl(String examId, String candidateId, String urlA, String urlB) {
        log.error("#人脸比对接口失败，进入熔断");
        throw new NestedBusinessException("人脸比对接口失败");
    }
    
    @Override
    public String getCandidateCheatState(String examId, String admissionNumber) {
    	log.error("#获取考生作弊状态失败，进入熔断");
        throw new NestedBusinessException("获取考生作弊状态失败");
    }
    
    @Override
    public String faceDetectByUrl(String examId, String candidateId, String imageUrl) {
    	log.error("#获取人脸识别失败，进入熔断");
        throw new NestedBusinessException("获取人脸识别失败");
    }
    
    @Override
    public String getLateAllowLoginInfo(String examId, String admissionNumber) {
    	log.error("#获取考生迟到允许登录信息失败，进入熔断");
        throw new NestedBusinessException("获取考生迟到允许登录信息失败");
    }

    @Override
    public String examAgainClearCandidateData(String examId, String examCandidateId) {
        log.error("#重置考生数据失败，进入熔断");
        throw new NestedBusinessException("重置考生数据失败");
    }
    
    @Override
    public String faceDetectEnrollPhotoByUrl(String examId, String examCandidateId, String imageUrl) {
    	 log.error("#人脸报名照片比对失败，进入熔断");
         throw new NestedBusinessException("人脸报名照片比对失败");
    }

    @Override
    public String getAppPlayAddress(String examCandidateId) {
        log.error("#获取移动端直播视频失败，进入熔断");
        throw new NestedBusinessException("获取移动端直播视频失败");
    }

    @Override
    public String existExam(String randomId) {
        log.error("#根据考试随机id查询考试是否存在失败，进入熔断");
        throw new NestedBusinessException("根据考试随机id查询考试是否存在失败");
    }
    
    @Override
    public String getAdmissionNumsByIdCardNum(String examId, String idCardNum) {
        log.error("#通过身份证获取准考证号失败，进入熔断");
        throw new NestedBusinessException("通过身份证获取准考证号失败");
    }

    @Override
    public String getAdmissionNumsByPhone(String examId, String code) {
        log.error("#通过手机号获取准考证号失败，进入熔断");
        throw new NestedBusinessException("通过手机号获取准考证号失败");
    }

    @Override
    public String getPaperListByPaperIdVersoin(String examId, String paperPackageId, String paperPackageVersion) {
        log.error("#通过试卷包Id、版本号获取试卷失败，进入熔断");
        throw new NestedBusinessException("通过试卷包Id、版本号获取试卷失败");
    }  
    
    @Override
    public String isXyExam(String examId) {
        log.error("#是否是兴业银行考试失败，进入熔断");
        throw new NestedBusinessException("是否是兴业银行考试失败");
    }   
    
    @Override
    public String saveXyCandidateReport(String json) {
        log.error("#保存兴业银行考生报告失败，进入熔断");
        throw new NestedBusinessException("保存兴业银行考生报告失败");
    }

    @Override
    public String getItem(String paperId, String paperVersion, String itemId) {
        log.error("#获取小题失败，进入熔断");
        throw new NestedBusinessException("获取小题失败");
    }

    @Override
    public String getPaperItemByTopicId(String paperId, String paperVersion, String topicId) {
        log.error("#获取小题失败，进入熔断");
        throw new NestedBusinessException("获取小题失败");
    }

    @Override
    public String getTopic(String paperId, String paperVersion, String topicId) {
        log.error("#获取大题失败，进入熔断");
        throw new NestedBusinessException("获取大题失败");
    }

    @Override
    public String checkIsCurrentPaper(String examId, String paperId, String paperVersion) {
        log.error("#检测是否当前考试绑定的试卷失败，进入熔断");
        throw new NestedBusinessException("检测是否当前考试绑定的试卷失败");
    }

    @Override
    public String getExamPaperInfo(String examId,String candidateId) {
        log.error("#获取试卷失败，进入熔断");
        throw new NestedBusinessException("获取试卷失败");
    }

    @Override
    public String checkExamStartTime(String examId) {
        log.error("#检测考试时间是否到失败，进入熔断");
        throw new NestedBusinessException("检测考试时间是否到失败");  
    }

    @Override
    public String feedbackWebsocketMessageResult(String msgCandidateId, String serverIP) {
        log.error("#反馈消息命中后的结果失败，进入熔断");
        throw new NestedBusinessException("反馈消息命中后的结果失败");
    }
    
    @Override
    public String getInterviewCandidateInfo(String candidateId) {
        log.error("获取面试所需考生信息失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("获取面试所需考生信息失败");
    }
    
    @Override
    public String getExamCustomization() {
    	 log.error("获取定制化考试信息失败.进入熔断，请检查考务模块服务");
         throw new NestedBusinessException("获取定制化考试信息失败");
    }

    @Override
    public String getExamCustomizationIsContainCodingPaper(String examId) {
        log.error("获取定制化考试是否包含编程题信息失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("获取定制化考试是否包含编程题信息失败");
    }
    
    @Override
    public String getCandidateJudgeScore(String candidateId) {
        log.error("获取定制化考试是否完成判分信息失败.进入熔断，请检查考务模块服务");
        throw new NestedBusinessException("获取定制化考试是否完成判分信息失败");
    }

    @Override
    public String clearCandidateData(CandidateDataInitDTO data) {
        log.error("清除考务清除考试考生表中的试卷信息失败，进入熔断，请检查教务模块服务");
        throw  new NestedBusinessException("清除考务清除考试考生表中的试卷信息失败");
    }

    @Override
    public String saveCandidatePhoto(String candidateId, String url, Integer photoFrom, Integer photoType) {
        log.error("保存考生照片失败，进入熔断，请检查教务模块服务");
        throw new NestedBusinessException("保存考生照片失败");
    }

    @Override
    public String updateCandidate(String json) {
        log.error("更新考生信息失败，进入熔断");
        throw new NestedBusinessException("更新考生信息失败");
    }

    @Override
    public String getExamCandidateById(String examCandidateId){
        log.error("查询考试考生信息失败，进入熔断");
        throw new NestedBusinessException("查询考试考生信息失败");
    }

    /**
     * 获取传入日期之后，完成考试及判分的考生ids
     * @param
     * @return
     */
    @Override
    public String getEndExamCandidateIds(EndExamCandidaeDTO dto){
        log.error("查询已完成考试且判分考生信息失败，进入熔断");
        throw new NestedBusinessException("查询已完成考试且判分考生信息失败");
    }


    /**
     * 获取传入日期之后，完成考试及判分的考生总数
     * @param
     * @return
     */
    @Override
    public String getEndExamCandidateCount(EndExamCandidaeDTO dto){
        log.error("查询已完成考试且判分考生总数失败，进入熔断");
        throw new NestedBusinessException("查询已完成考试且判分考生总数失败");
    }

    /**
     * 更新考试考生答题表是否已经备份
     * @param
     * @return
     */
    @Override
    public String updateExamCandidateAnswerIsBackup(List<String> candidateIds){
        log.error("更新考试考生答题表是否已经备份失败，进入熔断");
        throw new NestedBusinessException("更新考试考生答题表是否已经备份失败");
    }

    /**
     * 更新考试考生事件表是否已经备份
     * @param
     * @return
     */
    @Override
    public String updateExamCandidateLogIsBackup(@RequestBody List<String> candidateIds){
        log.error("更新考试考生事件表是否已经备份失败，进入熔断");
        throw new NestedBusinessException("更新考试考生事件表是否已经备份失败");
    }

    @Override
    public String updateCandidateUseTime(String examId, String candidateId, Long examUseTime) {
        log.error("更新考生用时失败，进入熔断");
        throw new NestedBusinessException("更新考生用时失败");
    }

    /**
     * 当考生选择重做-- 如果已备份--- 设置已备份为0
     * @param
     * @return
     */
    @Override
    public String updateExamCandidateBackupWenRodoExam(@RequestParam String candidateId){
        log.error("更新考试考生答题及事件表是否备份，进入熔断");
        throw new NestedBusinessException("更新考试考生答题及事件表是否备份");
    }
    
    @Override
    public String getCandidateConfig(String examId){
        log.error("获取考生信息采集，进入熔断");
        throw new NestedBusinessException("获取考生信息采集失败");
    }
    
    @Override
    public String getCandidateConfigInfo(String examId, String examCandidateId){
        log.error("获取考生信息，进入熔断");
        throw new NestedBusinessException("获取考生信息失败");
    }
    
    @Override
    public String getSubjectInfo(String paperId, String paperVersion){
        log.error("获取科目信息，进入熔断");
        throw new NestedBusinessException("获取科目信息失败");
    }
    
    @Override
    public String getEvalReport(String examId, String examCandidateId){
        log.error("获取考生信息，进入熔断");
        throw new NestedBusinessException("获取考生信息失败");
    }

    @Override
    public ApiResponse<Map<String, String>> getPaperTranslate(String language, String paperId, String paperVersion) {
        log.error("获取试卷翻译内容失败，进入熔断");
        throw new NestedBusinessException("获取试卷翻译内容失败");
    }

    @Override
    public ApiResponse<Map<String, String>> getAllExamPaper(String examId) {
        log.error("获取试卷失败，进入熔断");
        throw new NestedBusinessException("获取试卷失败");
    }
	@Override
    public ApiResponse<Boolean> getMobilePlayingStatus(String examId, String candidateId) {
        log.error("获取考生直播状态失败，进入熔断");
        throw new NestedBusinessException("获取考生直播状态失败");
    }

    @Override
    public ApiResponse<String> getExamIdByCode(Integer examCode) {
        log.error("删除考生初始化数据失败，进入熔断");
        throw new NestedBusinessException("删除考生初始化数据失败");
    }

	/**
     * 获取考试配置判断是否为现考现评
     *
     * @param examId
     * @return
     */
    @Override
    public String queryIsCurrentExam(@RequestParam String examId){
        log.error("获取考试配置判断是否为现考现评失败，进入熔断");
        throw new NestedBusinessException("获取考试配置判断是否为现考现评失败");
    }

    @Override
    public ApiResponse<List<TestingMessageDTO>> getCandidateMessageList(String examId, String candidateId) {
        log.error("获取消息对话列表失败，进入熔断");
        throw new NestedBusinessException("获取消息对话列表失败");
    }

    @Override
    public ApiResponse handUp(String examId, String candidateId) {
        log.error("考生举手失败，进入熔断");
        throw new NestedBusinessException("考生举手失败");
    }

    @Override
    public ApiResponse handUpCancel(String examId, String candidateId) {
        log.error("考生举手取消失败，进入熔断");
        throw new NestedBusinessException("考生举手取消失败");
    }

    /**
     *初始化数据进度增加
     * @param examId
     * @param num
     * @return
     */
    @Override
    public String addInitNum(@RequestParam String examId, @RequestParam Integer num){
        log.error("初始化数据进度增加失败，进入熔断");
        throw new NestedBusinessException("初始化数据进度增加失败");
    }

    /**
     *初始化清理数据进度增加
     * @param examId
     * @param num
     * @return
     */
    @Override
    public String addClearNum(@RequestParam String examId, @RequestParam Integer num){
        log.error("初始化清理数据进度增加失败，进入熔断");
        throw new NestedBusinessException("初始化清理数据进度增加失败");
    }

    /**
     *初始化清理数据总数
     * @param examId
     * @param num
     * @return
     */
    @Override
    public String addClearTotalNum(@RequestParam String examId, @RequestParam Integer num){
        log.error("初始化清理数据总数失败，进入熔断");
        throw new NestedBusinessException("初始化清理数据总数失败");
    }

    @Override
    public String overScreenLog(OverScreenLogVO overScreenLogVO) {
        log.error("切屏记录接口失败，进入熔断");
        throw new NestedBusinessException("切屏记录接口失败");
    }

    @Override
    public String getCandidateCount(@RequestParam String examId){
        log.error("获取考生总数失败，进入熔断");
        throw new NestedBusinessException("获取考生总数失败");
    }


    public String saveScreenShot(String examId, String candidateId, String screenShotUrl, String screenShotDate,@RequestParam Integer screenShotState) {
        log.error("保存截图失败，进入熔断");
        throw new NestedBusinessException("保存截图失败");
    }

    @Override
    public String updateCandidateFaceState(String candidateId) {
        log.error("回写考生通过人脸核身状态失败，进入熔断");
        throw new NestedBusinessException("回写考生通过人脸核身状态失败");
    }

    @Override
    public ApiResponse updateDeviceCheckState(DeviceCheckResultVO deviceCheckResultVO) {
        log.error("回写考生设备检测状态失败，进入熔断");
        throw new NestedBusinessException("回写考生设备检测状态失败");
    }

    /**
     * 二第登录验证人脸
     * @param examCandidateId
     * @param imageUrl
     * @param examId
     * @return
     */
    @Override
    public String secondValidFace(@RequestParam String examCandidateId, @RequestParam String imageUrl, @RequestParam String examId){
        log.error("二第登录验证人脸失败，进入熔断");
        throw new NestedBusinessException("二第登录验证人脸失败");
    }

    @Override
    public String unifiedLogin(String loginCode, String loginType) {
        log.error("统一登录失败，进入熔断");
        throw new NestedBusinessException("统一登录失败");
    }

    /**
     * 获取考生的app移动端监控状态
     * @param examCandidateId
     * @param examId
     * @return
     */
    @Override
    public String getAppPlayStatus(@RequestParam String examCandidateId,@RequestParam String examId){
        log.error("获取考生的app移动端监控状态失败，进入熔断");
        throw new NestedBusinessException("获取考生的app移动端监控状态失败");
    }

    @Override
    public String queryExamOfficePage(@RequestBody ExamOfficeRequestVO vo) {
        log.error("询考试机构分页数据失败，进入熔断");
        throw new NestedBusinessException("询考试机构分页数据失败");
    }

    @Override
    public ApiResponse<LoginInfo> getCandidateAdmissionNumber(String examId, String code, String loginType) {
        log.error("#考生登录获取准考证号失败，进入熔断");
        throw new NestedBusinessException("考生登录获取准考证号失败");
    }

    @Override
    public String getUnifiedLoginExamInfoList(String loginType, String admissionNumber, String name, String idCard, String phone) {
        log.error("#统一登录进入考试列表失败，进入熔断");
        throw new NestedBusinessException("统一登录进入考试列表失败");
    }

    public ApiResponse<Boolean> existCandidate(String examId, String admissionNumber) {
        log.error("#查询考生是否存在失败，进入熔断");
        throw new NestedBusinessException("查询考生是否存在失败");
    }

    @Override
    public ApiResponse updateCandidateAddTimeState(String candidateId) {
        log.error("#考生后会写状态失败，进入熔断");
        throw new NestedBusinessException("考生后会写状态失败");
    }

    @Override
    public ApiResponse updateNoticeState(MessageDTO messageDTO) {
        log.error("#考生确认写状态失败，进入熔断");
        throw new NestedBusinessException("考生确认写状态失败");
    }

    @Override
    public ApiResponse sendMessage2Candidate(WebsocketSendMessageDTO messageDTO) {
        log.error("#发送消息失败，进入熔断");
        throw new NestedBusinessException("发送消息失败");
    }

    @Override
    public ApiResponse updateLoginCount(String candidateId, Integer count) {
        log.error("#更新登录次数失败，进入熔断");
        throw new NestedBusinessException("更新登录次数失败");
    }

    @Override
    public ApiResponse updateCandidate(KwExamCandidate candidate) {
        log.error("#更新考生撤销状态失败失败，进入熔断");
        throw new NestedBusinessException("更新考生撤销状态失败失败");
    }

    @Override
    public ApiResponse<CandidateStateCountVO> getCandidateStateCount(@RequestParam String examId) {
        log.error("#获取考生状态人数失败失败，进入熔断");
        throw new NestedBusinessException("获取考生状态人数失败");
    }

    @Override
    public ApiResponse<Boolean> getCandidateForbidEndExam(@RequestParam String candidateId) {
        log.error("#获取获取考生强制收卷状态失败，进入熔断");
        throw new NestedBusinessException("获取获取考生强制收卷状态失败");
    }

    @Override
    public ApiResponse rewriteDataCheck(@RequestBody ExamDataCheckVO examDataCheckVO) {
        log.error("#回写数据核查失败，进入熔断");
        throw new NestedBusinessException("回写数据核查失败");
    }
}
